module D =
struct

  module Vec =
  struct
    let abs x =
      Lacaml.D.Vec.map abs_float x;;
    let sign x =
      Lacaml.D.Vec.map MLlab.Float.sign x;;
    let soft_threshold lambda x =
      Lacaml.D.Vec.map (MLlab.NonLinear.soft_threshold lambda) x;;
    let swap i j x =
      let tmp = x.{i} in
      x.{i} <- x.{j};
      x.{j} <- tmp;;
    let shuffle x =
      let n = Bigarray.Array1.dim x in
      for i = 1 to n
      do
        let j = (Random.int i) + 1 in
        swap i j x;
      done;
      x;;
  end

end
